import { createApp } from 'vue'
import router from './router'
import store from './store'
import './assets/CSS/global.css'
import ElementPlus from 'element-plus'
import 'element-plus/lib/theme-chalk/index.css'
import App from './App.vue'
import axios from 'axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// import TreeTable from 'vue-table-with-tree-grid'
axios.defaults.baseURL = 'https://lianghj.top:8888/api/private/v1/'

// {createApp}.prototype.$http = axios
// 通过接口获取菜单数据
// axios请求拦截添加token，保障拥有获取字段的权限
axios.interceptors.request.use(config => {
// 为请求对象，添加token验证的AUthorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  //   console.log(config)
  // 在request拦截中展示进度条 NProgress.Start()
  NProgress.start()
  return config
})
// 在response拦截中隐藏进度条 NProgress.done()
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})
const app = createApp(App)
// app.component('tree-table', TreeTable)
app.config.globalProperties.$http = axios
app.use(store).use(router).use(ElementPlus).mount('#app')
// app.filter('formatTime', function (value) {
//   console.log(value)
//   // const date = new Date(value)
//   // const hour = date.getHours()
//   // const minutes = date.getMinutes()
//   // const seconds = date.getSeconds()
//   // return `${hour}:${minutes}:${seconds}`
// })
